﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KBManagement.DAL;

namespace KBManagement.BIZ
{
    class FoodFacade:FacadeBase<Food>
    {


        public override IQueryable Select()
        {
            var foods = from fc in Library.Utils.CreateInstance().GetDBContext().Foods select new { fc.ID, fc.Fo_Name, fc.Price };
            return foods;
        }

        public override Food Find(object id)
        {
            return Library.Utils.CreateInstance().GetDBContext().Foods.Single(x => x.ID.Equals(id));
        }

        public Food FindByName(object name)
        {
            return Library.Utils.CreateInstance().GetDBContext().Foods.Single(x => x.Fo_Name.Equals(name));
        }

        public override Food[] FindMany(object id)
        {
            var foods = from fc in Library.Utils.CreateInstance().GetDBContext().Foods where (object)fc.FoodCategoryID == id select fc;
            return foods.ToArray();
        }
        public  IQueryable FindMany(int id)
        {
            var foods = from fc in Library.Utils.CreateInstance().GetDBContext().Foods where fc.FoodCategoryID == id select new { fc.ID, fc.Fo_Name, fc.Price };
            return foods;
        }

        public override Food[] SelectEntities()
        {
            var foods = from fc in Library.Utils.CreateInstance().GetDBContext().Foods select fc;
            return foods.ToArray();
        }        
    }
}
